Skip to content

Fix accurate AD summation in residual equations#1035

Open
Debraheem wants to merge 1 commit into
mainfrom
EbF/bugfix/accurate_ad_sums
Open

Fix accurate AD summation in residual equations#1035
Debraheem wants to merge 1 commit into
mainfrom
EbF/bugfix/accurate_ad_sums

Conversation

@Debraheem

@Debraheem Debraheem commented Jul 9, 2026

Copy link
Copy Markdown
Member

I believe the accurate AD summation types in mesa's residual equations were just being assigned the result of a normal AD expression sum, so the (dp) cancellation had already happened before the compensated summation logic even runs. So the accurate AD summation was not really being leveraged at all. I would call this an inconsequential bug, but fixing it could yield benefits.

This pr fixes the accurate AD sums to accumulate term-by-term through the accurate type, so each add/subtract actually uses the compensation algorithm. I added this type to a couple other locations where it might make sense (summing sources in hydro energy and in RSP2 turbulent energy and luminosity equations), and I did some minor clean up.

I'm not sure if this will help mesa convergence or not, it could in principle, but the point remains: this branch makes the intended behavior on main actually happen in practice. We will have to test and see if any thing changes in practice...

@Debraheem Debraheem added numerics issues with math/num/mtx modules solver labels Jul 9, 2026
@warrickball

warrickball commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

LGTM but double_bh is failing. I'll try to run this on bluebear tomorrow and see if I can get some output.

@warrickball

Copy link
Copy Markdown
Contributor

Not sure if you just need to rebase/merge main. The preceding commits also look like they had failures but main is clean.

@Debraheem

Copy link
Copy Markdown
Member Author

yeah, i plan to take a closer look soon as well. Might just need to merge main in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

numerics issues with math/num/mtx modules solver

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants